<?php
/*
+--------------------------------------------------------------------------
|   Anwsion [#RELEASE_VERSION#]
|   ========================================
|   by Tatfook Network Team
|   (c) 2011 - 2012 Anwsion Software
|   http://www.anwsion.com
|   ========================================
|   Support: zhengqiang@gmail.com
|   
+---------------------------------------------------------------------------
*/

class admin_session_class
{
	static function get_admin_uid()
	{
		return $_SESSION['admin_login'];
	}
	
	//检查登录
	static function check_admin_login($permission = array(), $uid = 0)
	{
		global $__controller;

		if(!$uid)
		{
			$uid = USER::get_client_uid();
		}
		
		$skip_controller = array(
			"login"
		);
		
		if (in_array($__controller, $skip_controller))
		{
			return true;
		}
		
		if (!isset($_SESSION['admin_login']) || ($_SESSION['admin_login'] != $uid))
		{
			$url = "/admin/login/";
			
			if (! empty($_SERVER['REQUEST_URI']))
			{
				$url .= "url-" . base64_encode($_SERVER['REQUEST_URI']);
			}
			
			HTTP::redirect($url);
		}
	}
}
